﻿@using Inovout.Kuajing.Exports.Models
@model Inovout.Kuajing.Exports.Models.TraditionalOrder
@{
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}

@section styles {

    <style>
        .form form {
            margin: 20em auto;
        }

        .logisticForm {
            margin-top: 3em;
        }

            .logisticForm select {
                max-width: 280px;
            }


    </style>
}

@section scriptsHead {
    <script type="text/javascript">
        $(document).ready(function () {
            $("#ExpectedDeclarationDate").datepicker();


            $("#DeclarationPortName").val($("#DeclarationPortCode option:selected").text());
            $('#DeclarationPortCode').on('change', function () {
                $("#DeclarationPortName").val($("#DeclarationPortCode option:selected").text());
            });


            $("#ExportCountryName").val($("#ExportContryCode option:selected").text());
            $('#ExportContryCode').on('change', function () {
                $("#ExportCountryName").val($("#ExportContryCode option:selected").text());
            });

            $("#DeliveryCityName").val($("#DeliveryCityCode option:selected").text());
            $('#DeliveryCityCode').on('change', function () {
                $("#DeliveryCityName").val($("#DeliveryCityCode option:selected").text());
            });
            @{
                int selected = Model.PackingWay == PackingWay.Bulkcargo ? 1 : 0;
              }
            $("#PackingWay").val('@selected');

        });

    </script>
}

<div>
    @using (Html.BeginForm("LocateLogistic", "TraditionalOrder", FormMethod.Post, new { @class = "form-horizontal logisticForm" }))
    {
        <div class="form-group">
            @Html.LabelFor(model => model.DeclarationPortName, "报关口岸", new { @for = "DeclarationPortName", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @{
                    <select name="DeclarationPortCode" id="DeclarationPortCode" class="form-control">
                        <option value="1" selected="selected">南京关</option>
                        <option value="2">上海关</option>
                    </select>
                }
            </div>
            @Html.HiddenFor(mode => mode.DeclarationPortName)
            @Html.HiddenFor(model => model.Id)
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.PackingWay, "装箱方式", new { @for = "Country", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                <select class="form-control" name="PackingWay" id="PackingWay">
                    @{
        int box = (int)PackingWay.Bulkcargo;
        int container = (int)PackingWay.Container;
                        <option value="@box">整箱</option>
                        <option value="@container">散货</option>
                    }
                </select>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Container20, "20尺柜（个）", new { @for = "Container20", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(mode => mode.Container20, new { @class = "form-control" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.Container40, "40尺柜（个）", new { @for = "Container40", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(mode => mode.Container40, new { @class = "form-control" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.Container46, "46尺柜（个）", new { @for = "Container46", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(mode => mode.Container46, new { @class = "form-control" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.ExportCountryName, "目的国", new { @for = "ExportContryCode", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.DropDownListFor(model => model.ExportContryCode, (SelectList)ViewData["countries"], new { @class = "form-control" })
                @Html.HiddenFor(model => model.ExportCountryName)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.DeliveryCityName, "货源地", new { @for = "DeliveryCityCode", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.DropDownListFor(model => model.DeliveryCityCode, (SelectList)ViewData["cities"], new { @class = "form-control" })
                @Html.HiddenFor(model => model.DeliveryCityName)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ExpectedDeclarationDate, "预计截至报关时间", new { @for = "ExpectedDeclarationDate", @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(mode => mode.ExpectedDeclarationDate, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input type="submit" id="logisticSubmit" class="btn btn-default" value="下单结束" />
            </div>
        </div>

    }
</div>
